package org.itboys.mobile.controller.web;

import org.itboys.commons.CommonConstants;
import org.itboys.commons.dto.ResultPageDOHelper;
import org.itboys.commons.utils.ajax.AjaxUtils;
import org.itboys.framework.query.JsonPageUtils;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.mobile.entity.mongo.SundayAdvertisementZone;
import org.itboys.mobile.entity.mysql.product.SundayProduct;
import org.itboys.mobile.service.KitchenDesktopService;
import org.itboys.mobile.service.mysql.web.product.SundayProductService;
import org.itboys.param.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 作者：jiangxiong
 * 日期：2017年5月8日
 * 联系方式 ：empty90911@126.com
 * 描述：农厨_后台首页_service
 */
@Controller
@RequestMapping("/kitchen/web/desktop")
public class KitchenDesktopController extends BaseController {

    @Autowired
    private KitchenDesktopService desktopService;

    /**
     * 质押物  主页
     * @param request
     * @param model
     * @return
     */
    @RequestMapping("/index" )
    public  String index(HttpServletRequest request,
                           Model model){
        Map<String,Object> result=desktopService.getDesktopDate();
        model.addAttribute("result",result);
       return "/kitchen/desktop/index";
    }
    /**
     * 获取提示消息的数据
     * @param request
     * @param response
     */
    @RequestMapping("/alert")
    public void alert(HttpServletRequest request,
                            HttpServletResponse response
    ) {
        try {
            Map<String,Object> result=desktopService.alert(request);
            AjaxUtils.renderJsonporJson(response, null,
                    ResultPageDOHelper.getMsgResultDO(result,CommonConstants.SUCCESS));
        } catch (Exception e) {
            e.printStackTrace();
            AjaxUtils.renderJsonporJson(response, null,
                    ResultPageDOHelper.getMsgCodeResultDO(CommonConstants.FAIL_CODE, CommonConstants.FAIL));
        }
    }


}
